package cn.edu.usst.cs.time;

import java.lang.reflect.Field;
import java.util.Scanner;

public class Reflect {
    public static void main(String[] args) {
        while (true){
            try (Scanner scanner = new Scanner(System.in)) {
                System.out.println("Please input the class name:");
                String className = scanner.nextLine();
                Class<?> clazz = Class.forName(className);
                System.out.println("The class name is: " + clazz.getName());
                Field[] fields = clazz.getDeclaredFields();
                for (Field field : fields) {
                    System.out.println(field);
                }
            } catch (ClassNotFoundException e) {
                System.out.println("Class not found.");
                break;
            }catch (RuntimeException e){
                System.out.println(e.getLocalizedMessage());
                break;
            }
        }
    }
}
